package com.example.demo.converter;

import com.example.demo.dao.Outfit;
import com.example.demo.dto.OutfitDTO;

import java.util.HashSet;
import java.util.Set;

public class OutfitConverter {
    public static OutfitDTO convertOutfit(Outfit outfit) {
        OutfitDTO outfitDTO = new OutfitDTO();
        outfitDTO.setId(outfit.getId());
        outfitDTO.setName(outfit.getName());
        outfitDTO.setDescription(outfit.getDescription());
        outfitDTO.setClothes(ClothConverter.convertToClothDTOSet(outfit.getClothes()));
        outfitDTO.setUserDTO(UserConverter.convertUser(outfit.getUser()));
        outfitDTO.setCategory(outfit.getCategory());
        return outfitDTO;
    }

    public static Outfit convertOutfit(OutfitDTO outfitDTO) {
        Outfit outfit = new Outfit();
        outfit.setId(outfitDTO.getId());
        outfit.setName(outfitDTO.getName());
        outfit.setDescription(outfitDTO.getDescription());
        outfit.setCategory(outfitDTO.getCategory());
        outfit.setClothes(ClothConverter.convertToClothSet(outfitDTO.getClothes()));
        outfit.setUser(UserConverter.convertUser(outfitDTO.getUserDTO()));
        return outfit;
    }
    public static Set<OutfitDTO> convertToOutfitDTOSet(Set<Outfit> outfits) {
        Set<OutfitDTO> outfitDTOSet = new HashSet<>();
        for (Outfit outfit : outfits) {
            outfitDTOSet.add(convertOutfit(outfit));
        }
        return outfitDTOSet;
    }
    public static Set<Outfit> convertToOutfitSet(Set<OutfitDTO> outfitDTOSet) {
        Set<Outfit> outfits = new HashSet<>();
        for (OutfitDTO outfitDTO : outfitDTOSet) {
            outfits.add(convertOutfit(outfitDTO));
        }
        return outfits;
    }

}
